

using System;
using Dapper;
using Microsoft.Data.Sqlite;
using zvideo.Models;

namespace zvideo.utils;

public static class Db
{
    private const string DbPath = @"C:\Users\zengh\RiderProjects\zvideo\utils\zvideo.db";

    public static void Select()
    {
        //string dbPath = "/utils/zvideo.db";
        string connectionString = $"Data Source= {DbPath}";

        using (var connection = new SqliteConnection(connectionString))
        {

            try
            {
                //connection.Open();
                
                Console.WriteLine("Connected to SQLite! ");

                //string sql = "SELECT id, username, password FROM tb_users";
                var us= connection.Query<Users>("SELECT id, username, password FROM tb_users");
                foreach (var u in us)
                {
                    Console.WriteLine(u.ToString());
                }
                
               
            }
            catch (Exception e)
            {
                Console.WriteLine("An Error occurred: " + e.Message);
               
            }
        }
    }
}